<template>
	<view class="mysettle">
		<label class="settle-radios">
		  <radio color="#c00000" :checked="isFullCheck" @click="changeChecked" /><text>全选</text>
		</label>
    <view class="settle-box">
      合计:<text>￥{{ checkedMany }}</text>
    </view>
    <view class="settle-btn" @click="toPay">
      结算({{ checkedCount }})
    </view>
	</view>
</template>

<script>
  import { mapGetters, mapMutations, mapState } from 'vuex'
	export default {
		name:"my-settle",
		data() {
			return {
			};
		},
    computed: {
      ...mapState('user', ['token']),
      ...mapGetters('user', ['addr']),
      ...mapGetters('cart', ['checkedCount', 'total', 'checkedMany']),
      isFullCheck () {
        if(this.checkedCount === this.total) return true
        return false
      }
    },
    methods: {
      ...mapMutations('cart', ['updataAllState']),
      changeChecked () {
        // console.log(1)
          this.updataAllState(!this.isFullCheck)
      },
      toPay () {
        console.log(1)
        if(!this.checkedCount) return uni.$showMsg('请选择要结算的商品')
        if(!this.addr) return uni.$showMsg('请选择收货地址')
        if(!this.token) return uni.$showMsg('请登录...')
      }
    }
	}
</script>

<style lang="scss">
.mysettle {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 50px;
  width: 100%;
  font-size: 14px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 5px;
  .settle-radios {
    display: flex;
    align-items: center;
  }
  .settle-box {
    text {
      color: #c00000;
    }
  }
  .settle-btn {
    height: 50px;
    min-width: 100px;
    line-height: 50px;
    text-align: center;
    background-color: #c00000;
    color: #fff;
  }
}
</style>
